package gene.android.accountingpro.equations;

import gene.android.accountingpro.finals.EquationNames;
import gene.android.accountingpro.finals.FieldList;

import java.util.ArrayList;
import java.util.List;

public class ReturnOnAssetsRatio extends Equation {
	
	private double net_income;
	private double interest_expense;
	private double average_assets;
	
	public ReturnOnAssetsRatio(){}
	
	public ReturnOnAssetsRatio( double netIncome, double interestExpense, double averageAssets )
	{
		this.net_income = netIncome;
		this.interest_expense = interestExpense;
		this.average_assets = averageAssets;
		value = ( ( net_income + interest_expense ) / average_assets );
	}
	
	

	@Override
	public String getEquationName() {
		return EquationNames.RETURN_ON_ASSETS_RATIO;
	}

	@Override
	public List<String> getRequiredFields() {
		List<String> requiredFields = new ArrayList<String>();
		requiredFields.add( FieldList.NET_INCOME );
		requiredFields.add( FieldList.INTEREST_EXPENSE );
		requiredFields.add( FieldList.AVERAGE_ASSETS );
		return requiredFields;
	}

	@Override
	public void setValues(double[] values) {
		net_income = values[0];
		interest_expense = values[1];
		average_assets = values[2];
		solve();
	}

	@Override
	public String getSolvedEquationString() {
		return "( ( " +net_income + " + " + interest_expense +" ) / ( " + average_assets +" ) ) = " +value;
	}

	@Override
	public String getEquationString() {
		return "( ( " +FieldList.NET_INCOME + " + " + FieldList.INTEREST_EXPENSE +" ) / ( " + FieldList.AVERAGE_ASSETS +" ) )";
		
	}

	@Override
	public void solve() {
		value = ( ( net_income + interest_expense ) / average_assets );
	}

}
